package cn.xuetian.mqtest.controller;

import java.util.UUID;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/test1")
public class Test1Controller {

    @Autowired
    private RabbitTemplate rabbitTemplate;


    @Value("${demo.mymqTest.exchange}")
    private String exchange;

    @GetMapping("/test1")
    public String test1() {

        String msg = "aaaaaaaaaaAAAAAAAAAAAAAAAAAAAAA" + UUID.randomUUID().toString();

        rabbitTemplate.convertSendAndReceive(exchange,"routingKey1",msg);

//        rabbitTemplate.convertAndSend(msg);

        return UUID.randomUUID().toString();
    }

}
